﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace Bookvar.UI.Converters
{
    internal class InterceptedBackwardConverter : IValueConverter
    {
        private readonly Action<object> action;

        public InterceptedBackwardConverter( Action<object> action )
        {
            this.action = action;
        }

        public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
        {
            return value;
        }

        public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
        {
            action( value );

            return Binding.DoNothing;
        }
    }
}
